

<template>
  <el-dialog title="发布工作" :visible.sync="addJobShow">
    <el-form>
      <el-form-item label="工作名称">
        <el-input v-model="form.title" placeholder="请输入工作名称"></el-input>
      </el-form-item>
      <el-form-item label="报酬">
        <el-input v-model="form.salary" placeholder="请输入报酬" type="number"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button size="small" type="info" @click="close">取消</el-button>
      <el-button size="small" type="primary" @click="pushJob">确定</el-button>
    </div>
  </el-dialog>
</template>
<script>
  import {pushJobApi} from "@/api/qingongjianxue";

  export default {
    data(){
      return {
        form: {
          title: '',
          salary: ''
        }
      }
    },
    computed: {
      privateKey(){
        return this.$store.state.app.user_info.privateKey
      }
    },
    props: {
      addJobShow: {
        type: Boolean,
        default: false
      },

    },
    methods: {
      close(){
        this.$emit('close')
      },
      //发布工作
      async pushJob(){
        if(!this.form.title){
          this.$message.error('请输入工作名称')
          return
        }
        if(!this.form.salary){
          this.$message.error('请输入报酬')
          return
        }
        const res = await pushJobApi({
          ...this.form,
          privateKey: this.privateKey
        })
        this.$emit('success')
        this.$emit('close')
      },
    }

  }
</script>
<style scoped lang="scss">

</style>
